<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
if($_RQ['op']=='main'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择项目','error');
	}
	$item=$this->plugin_setting('setting');
	$return['info']=pdo_get('jy_cmspinche_list',array('id'=>$id));
	$type=array('1'=>'拼车','2'=>'带客');
	$v=$return['info']['type'];
	$return['info']['type']=$type[$v];
	$k=array('0'=>'不拼座','1'=>'拼座');
	$s=$return['info']['self'];
	$return['info']['self']=$k[$s];
	$return['info']['time']=date('Y-m-d H:i:s',$return['info']['time']);
	$return['type']=$_RQ['type'];
	$_SESSION['pincheid']=$id;
	$return['sharedata']=array(
			'title'=>$item['share_title']?$item['share_title']:'我分享了一个'.$type.'信息',
			'desc'=>$item['share_desc']?$item['share_desc']:$return['info']['title'],
			'link'=>custom_url('jy_cmspinche/detail//id='.$id,true),
			'imgUrl'=>ATTACHMENT_URL.$item['share_image'],
	);
	exi($return);
}
if($_RQ['op']=='do'){
	$id=$_SESSION['pincheid'];
	$uid=pdo_getcolumn('jy_cmspinche_list',array('id'=>$id),'uid');
	if($uid==$_SESSION['uid']){
		exi('不可预定自己发布的拼车','error','home/');
	}
	$item=pdo_get('jy_cmspinche_log',array('pid'=>$id,'inuid'=>$_SESSION['uid']));
	if($item){
		exi('不可重复预定','error','home/');
	}
	$return['info']=pdo_get('jy_cmspinche_log',array('inuid'=>$_SESSION['uid']),array('name','mobile'),'id desc');
	$return['op']='do';
	exi($return);
}
if($_RQ['op']=='yuding'){
	$postdata=get_postdata();
	$id=$_SESSION['pincheid'];
	if(!$postdata['mobile']){
		exi('请填写联系电话','error');
	}
	if(!$postdata['name']){
		exi('请填写联系人','error');
	}
	$uid=pdo_getcolumn('jy_cmspinche_list',array('id'=>$id),'uid');
	$data=array_fields(array('remark','mobile','name'),$postdata);
	$data['uniacid']=$_SESSION['uniacid'];
	$data['inuid']=$_SESSION['uid'];
	$data['createtime']=TIMESTAMP;
	$data['pid']=$id;
	$data['uid']=$uid;
	pdo_insert('jy_cmspinche_log',$data);
	exi('预定成功！','','home/');
	
}
?>